from fastapi.responses import HTMLResponse, JSONResponse, PlainTextResponse
from fastapi import APIRouter, Depends
from fastapi.encoders import jsonable_encoder
from config import get_settings, Settings
from typing import Annotated
import os


# Create a router with a general tag for API documentation organization
router = APIRouter(tags=["General"])


@router.get("/")
async def homepage():
    """Root endpoint that returns a simple HTML welcome page"""
    html_content = (
        "<h1>Scrape Poetry MCP SERVER</h1>"
        "<p>Welcome to the scrape poetry server with MCP integration.</p>"
    )
    return HTMLResponse(html_content)


@router.get("/about")
async def about():
    """About endpoint that returns information about the application"""
    return PlainTextResponse(
        "About Scrape Poetry MCP SERVER: Scrape Poetries "
        "with Model Context Protocol integration."
    )


@router.get("/status")
async def status(settings: Annotated[Settings, Depends(get_settings)]):
    """Status endpoint that returns the current server status"""
    status_info = {
        "status": "running",
        "server": "Scrape Poetry MCP SERVER",
        "version": "0.1.0",
        "bucket": os.getenv("BUCKET_NAME"),
        "AWS_ACCESS_KEY_ID": os.getenv("AWS_ACCESS_KEY_ID"),
        "AWS_ENDPOINT_URL_S3": os.getenv("AWS_ENDPOINT_URL_S3"),
        # "settings": jsonable_encoder(settings),
    }
    
    return JSONResponse(status_info)
